<?php

namespace app\common\model;

use think\Model;
use think\Session;

class AgentInfo extends Model
{

    public function agent()
    {
        return $this->belongsTo(Agent::class, 'agent_id', 'id');
    }

    public function saveByAgentId($agentId, $data)
    {
        $data['agent_id'] = $agentId;
        if (!$this->where('agent_id', $agentId)->count()) {
            return $this->insert($data);
        }
        return $this->save($data, [
            'agent_id' => $agentId
        ]);
    }

}
